/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean;

import com.lowagie.text.BadElementException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import java.io.File;
import java.io.IOException;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.faces.bean.ManagedBean;
/**
 *
 * @author thanhle
 */
@ManagedBean(name = "export")
@RequestScoped
public class export {
    

   
      
    public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException {  
        Document pdf = (Document) document;  
        pdf.open();  
        pdf.setPageSize(PageSize.A4);  
      
        ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();  
        String logo = servletContext.getRealPath("") + File.separator + "images" + File.separator + "logo.jpg";  
      
        pdf.add(Image.getInstance(logo));  
    }  
}
